<?php
/**
 * The template for displaying Category pages.
 *
 * Used to display archive-type pages for posts in a category.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Twelve
 * @since Twenty Twelve 1.0
 */

get_header(); ?>

	<div id="primary">
		<nav role="navigation" class="site-navigation page-navigation">
				<h1 class="assistive-text"><?php _e( 'Menu', 'tsv-bierden' ); ?></h1>
				<div class="assistive-text skip-link"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'tsv-bierden' ); ?>"><?php _e( 'Skip to content', 'tsv-bierden' ); ?></a></div>
	
				<?php wp_nav_menu( array( 'theme_location' => 'secondary' ) ); ?>
		</nav>
		<?php get_sidebar('Sidebar'); ?>
	</div> <!-- #primary -->
	<div id="secondary" class="site-content">
		<div id="content" role="main">

		<?php if ( have_posts() ) : ?>
			<header class="archive-header">
				<h1 class="archive-title"><?php printf( __( 'Category Archives: %s', 'tsv-bierden' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>

			<?php if ( category_description() ) : // Show an optional category description ?>
				<div class="archive-meta"><?php echo category_description(); ?></div>
			<?php endif; ?>
			</header><!-- .archive-header -->
			<ul id="<?php single_cat_title('', true); ?>">
			<?php
			/* Start the Loop */
			if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
					<li id="post-<?php the_ID(); ?>" <?php post_class();?>>
					<?php
					//@todo check what happens if more than one link are in the text
						$content = get_the_content();
						$s = explode('href="',$content);
						$t = explode('>',$s[1]);
						unset($t[1]);
						$link = implode('', $t);
						echo '<a href="' . $link . '">' . get_the_time('m/j/Y') . ' ' , the_title() . '</a>';  
					?>
					</li>
			<?php endwhile; // end of the loop. ?>
			</ul>
		<?php else : ?>
			<article id="post-0" class="post no-results not-found">

			<?php if ( current_user_can( 'edit_posts' ) ) :
				// Show a different message to a logged-in user who can add posts.
			?>
				<header class="entry-header">
					<h1 class="entry-title"><?php _e( 'No posts to display', 'tsv-bierden' ); ?></h1>
				</header>

				<div class="entry-content">
					<p><?php printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.', 'tsv-bierden' ), admin_url( 'post-new.php' ) ); ?></p>
				</div><!-- .entry-content -->

			<?php else :
				// Show the default message to everyone else.
			?>
				<header class="entry-header">
					<h1 class="entry-title"><?php _e( 'Nothing Found', 'tsv-bierden' ); ?></h1>
				</header>

				<div class="entry-content">
					<p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'tsv-bierden' ); ?></p>
					<?php get_search_form(); ?>
				</div><!-- .entry-content -->
			<?php endif; // end current_user_can() check ?>

			</article><!-- #post-0 -->
		<?php endif; ?>

		</div><!-- #content -->
	</div><!-- #secondary -->

<?php get_footer(); ?>